import java.util.List;

import util.MoveParser;
import util.PGNBasicReader;
import beans.Color;
import beans.Move;
import board.Board;
import board.Game;


public class TestingBoard {
	
	public static void main(String args[]) throws Exception{		
		List<Game> games = PGNBasicReader.read("./testFiles/NextTime_vs_JOSEPOT_2012_01_17.pgn");		
		
		int ok=0;
		int ko=0;
		
		for(Game game:games){			
			List<Move> moves = game.getMoves();			
			Board board =new Board();
			StringBuilder sb1 = new StringBuilder();
			StringBuilder sb2 = new StringBuilder();
			int i=0;			
			for(Move move:moves){
				sb1.append(move.getShortAlgebraicNotation()).append(' ');				
			}
			//System.out.println(sb1.toString());
			for(Move move:moves){				
				Color turn = ((i%2)==0)?Color.WHITE:Color.BLACK;				
				Move newMove = MoveParser.fromLongNotation(move.toLongAlgebraicFormat(), board, (i+2)/2);				
				sb2.append(newMove.getShortAlgebraicNotation()).append(' ');				
				//System.out.println("Move " + ((i/2)+1) + " " + turn );
				//board.printIt(true);
				//System.out.println(move.getShortAlgebraicNotation());
				//System.out.println();			
				i++;
			}
			//System.out.println(sb2.toString());
			if(sb1.toString().equals(sb2.toString())){
				ok++;
			}else{
				ko++;
				System.out.println(game.getRawGame());
				System.out.println(sb1.toString());
				System.out.println(sb2.toString());
				System.out.println();
			}			
		}
		System.out.println("ok: " + ok + ", ko:" + ko);
	}
}
